<?php

namespace app\modules\order\controllers;

use Yii;
use yii\web\Controller;
use common\models\Order;
use common\models\Tools;

/**
 * 订单列表
 */
class DefaultController extends Controller
{
    /**
     * Renders the index view for the module
     * @return string
     */
	public $leftmenu;
    public function actionIndex()
    {
        //检测登录情况
        if (Yii::$app->user->isGuest) {
            return $this->redirect('/site/login?returnurl=/order');
        }
        $condition = [];
        $condition['first_cate'] = Tools::GetSafeParam('first_cate', 0, 0);
        
        
        $userid = Yii::$app->user->identity->id;
        
        $page_no = Tools::GetSafeParam('page_no', 1, 0);
        
        $data = Order::getOrderList($userid,$condition,$page_no);
        
        $page = Tools::showCmPager($page_no, $data['perpage'], $data['total'],$condition);
        $this->layout = "/personal";
        $this->leftmenu='order';
  //       echo "<pre>"; 
		// print_r($data);exit;
        // return $this->render('index',['data'=>$data,'page'=>$page]);
		return $this->render('index',[
		    'data' => $data,
		    'page' => $page,
			'backend_server' => Yii::$app->params['backend_server'],
		    'condition' => $condition,
		    ]);
    }
}
